#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<list>
#include<cstdlib>
#include<cmath>
#include<sstream>
#include<numeric>
#include<cstdio>
#include<cstring>
#include<stack>
#define PI acos(-1)
#define MP make_pair
#define PB push_back
#define VI vector <int>
#define PII pair <int,int>
#define LL long long
#define SET(v,i) memset(v, i, sizeof(v))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)
#define FORN(i,a,b) for (int i = (a); i < (b); i++)
#define DOWN(i,a,b) for (int i = (a); i > (b); i--)
#define FIT(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); it++)
#define FITD(it,v) for (typeof(v.rbegin()) it = v.rbegin(); it != v.rend(); it++)
using namespace std;
const int N=3005;
vector<pair<int,int> >v[N];
int a[N],b[N],cnt,res;
void dfs(int x,int pr,int tmp){
	res=max(res,tmp);
	for(int i=0;i<v[x].size();i++)if(v[x][i].first!=pr){
		cnt+=v[x][i].second;
		dfs(v[x][i].first,x,max(0,tmp+v[x][i].second*2-1));
		}
	}
int main(){
	int n;
	cin>>n;
	for(int i=1;i<n;i++){
		int x,y;
		cin>>x>>y;x--;y--;
		v[x].push_back(make_pair(y,0));
		v[y].push_back(make_pair(x,1));
		}
	int ans=n;
	for(int i=0;i<n;i++){
		cnt=res=0;
		dfs(i,i,0);
		ans=min(ans,cnt-res);
		}
	cout<<ans<<endl;while(1);
    return 0;
    }
